package com.shopx.auth.controller;

import com.shopx.auth.bean.SysUserRole;
import com.shopx.auth.model.SysUserRoleModel;
import com.shopx.auth.service.ISysUserRoleService;
import com.shopx.base.anno.RepearSubmitChkAnno;
import com.shopx.base.anno.ShopxParamAnno;
import com.shopx.base.controller.BaseController;
import com.shopx.base.dto.Result;
import com.shopx.base.exception.ShopxException;
import com.shopx.base.utils.ResultUtil;
import com.shopx.cmm.DTO.PageDTO;
import com.shopx.core.common.CommonConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lituo
 * @className: SysConfigController
 * @description: 用户角色
 * @date 2021/12/5 12:04 PM
 */
@RestController
@Slf4j
@RequestMapping(value = "/sysUserRole")
public class SysUserRoleController extends BaseController {

  @Autowired
  private ISysUserRoleService sysUserRoleService;

  @RequestMapping(value = "/queryPageList")
  @ShopxParamAnno
 public Result<?> queryPageList(@RequestBody SysUserRoleModel sysUserRole) throws ShopxException {
    PageDTO<SysUserRoleModel> pageDTO = sysUserRoleService.getListPage(sysUserRole);
    return ResultUtil.ok(pageDTO);
  }

  @RequestMapping(value = "/insertOne")
  @RepearSubmitChkAnno(lockTime = CommonConstant.REQ_TM)
  @ShopxParamAnno
 public Result<?> insertOne(@RequestBody SysUserRole sysUserRole) throws ShopxException {
    int result = sysUserRoleService.insertSelective(sysUserRole);
    return ResultUtil.ok(result);
  }

  @RequestMapping(value = "/updateOne")
  @RepearSubmitChkAnno(lockTime = CommonConstant.REQ_TM)
  @ShopxParamAnno
 public Result<?> updateOne(@RequestBody SysUserRole sysUserRole) throws ShopxException {
    int result = sysUserRoleService.updateByPrimaryKeySelective(sysUserRole);
    return ResultUtil.ok(result);
  }

  @RequestMapping(value = "/queryOneByPrimaryKey")
  @ShopxParamAnno
 public Result<?> queryOneByPrimaryKey(@RequestBody SysUserRole sysUserRole) throws ShopxException {
    SysUserRoleModel result = sysUserRoleService.selectByPrimaryKey(sysUserRole);
    return ResultUtil.ok(result);
  }

  //@RequestMapping(value = "/deleteChecked")
  //public ModelAndView deleteChecked(SysUserRole sysUserRole) throws ShopxException {
  //int result = sysUserRoleService.deleteByPrimaryKey(sysUserRole);
  //return new ModelAndView(SysView.CROSS_VIEW, SysView.TRANS_DATA, result);
  //}
}

